<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserPlatform extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $primaryKey = 'user_id';
    protected $connection = 'manager';

    public $timestamps = false;

    public static function ids(int $user_id) : array
    {
        $UP = UserPlatform::where("user_id", $user_id)->where("platform_id", "<>", -1)->get();

        $array = [];
        foreach($UP as $up) {
            $array[] = $up->platform_id;
        }

        return $array;
    }

    public static function isAll(int $user_id) : bool
    {
        if ($user_id == 1) {
            return true;
        }
        
        return UserPlatform::where("user_id", $user_id)->where("platform_id", -1)->first() ? true : false;
    }
}
